package com.kqkj.dyrule.marketing.utils;

import com.alibaba.fastjson.JSON;
import com.kqkj.dyrule.marketing.beans.MarketingRule;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

public class RuleSimulatorFromJson {

    public static List<MarketingRule> getRule() throws IOException {
        String json1 = FileUtils.readFileToString(new File("rule_engine/rules/rule1.json"),"utf-8");

        MarketingRule rule1 = JSON.parseObject(json1, MarketingRule.class);

        String json2 = FileUtils.readFileToString(new File("rule_engine/rules/rule2.json"),"utf-8");

        MarketingRule rule2 = JSON.parseObject(json2, MarketingRule.class);

        return Arrays.asList(rule1,rule2);
    }
}
